/**
 * Created by Administrator on 15-10-9.
 */
window.onload=function(){
//    var geolocation = new BMap.Geolocation();
//    geolocation.getCurrentPosition(function(r) {
//        var storage = window.localStorage;
//        storage.setItem("lng", r.point.lng);
//        storage.setItem("lat", r.point.lat);
//    });



    var url = getUrl();
    var userid=getUserId();
    var birthday=$.getUrlParam("birthday");
    $.jsonp({
        url: 'http://'+url+'/api/user/'+userid+'/select',
        data: {},
        callbackParameter: "callback",
        success: function (data,textStatus,xOptions) {

            var birthday=data.user.birthday;
            $("#birthday").text(birthday);
            var date=new Date(birthday);
            //console.log(xingzuo(date.getMonth()+1,date.getDate()))
            $("#xingzuo").text(xingzuo(date.getMonth()+1,date.getDate()));
        },
        error: function (xOptions, textStatus) {
        }

    });
    $.jsonp({
        url: 'http://'+url+'/api/user/main',
        data: {userId:userid},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            //alert("111");
            var nickName = data.nickName;
            $("#nickName").text(nickName);
            var photo = data.photo;
            $("#photo").attr('src',photo);
            var age = data.age;
            $("#age").text(age);
            var charisma = data.charisma;
            $("#charisma").text(charisma);
            var sex=data.sex;
            if(data.sex==1){
                $("#sexicon").addClass("icons-sex-male");
                $("#sex").addClass("sex sex-male");
                //icons-sex-female
            }else{
                $("#sexicon").addClass("icons-sex-female");
                $("#sex").addClass("sex sex-female");
            }
        },
        error: function (xOptions,textStatus) {
//        alert("2222");
        }
    })


    //获取未读数量
    var storage = window.localStorage;
    var count = storage.getItem("unreadCount");
    if (count == null){
        count = 0;
    }
    $("#count").text(""+count+"");
//    getUnReadNum();
}
function onBackKeyDown() {
    jumpbyback(0,"");
    }
function xingzuo(month,date) {
        var value="";
        if (month == 1 && date >=20 || month == 2 && date <=18) {value = "水瓶座";}
        if (month == 1 && date > 31) {value = "Huh?";}
        if (month == 2 && date >=19 || month == 3 && date <=20) {value = "双鱼座";}
        if (month == 2 && date > 29) {value = "Say what?";}
        if (month == 3 && date >=21 || month == 4 && date <=19) {value = "白羊座";}
        if (month == 3 && date > 31) {value = "OK. Whatever.";}
        if (month == 4 && date >=20 || month == 5 && date <=20) {value = "金牛座";}
        if (month == 4 && date > 30) {value = "I'm soooo sorry!";}
        if (month == 5 && date >=21 || month == 6 && date <=21) {value = "双子座";}
        if (month == 5 && date > 31) {value = "Umm ... no.";}
        if (month == 6 && date >=22 || month == 7 && date <=22) {value = "巨蟹座";}
        if (month == 6 && date > 30) {value = "Sorry.";}
        if (month == 7 && date >=23 || month == 8 && date <=22) {value = "狮子座";}
        if (month == 7 && date > 31) {value = "Excuse me?";}
        if (month == 8 && date >=23 || month == 9 && date <=22) {value = "处女座";}
        if (month == 8 && date > 31) {value = "Yeah. Right.";}
        if (month == 9 && date >=23 || month == 10 && date <=22) {value = "天秤座";}
        if (month == 9 && date > 30) {value = "Try Again.";}
        if (month == 10 && date >=23 || month == 11 && date <=21) {value = "天蝎座";}
        if (month == 10 && date > 31) {value = "Forget it!";}
        if (month == 11 && date >=22 || month == 12 && date <=21) {value = "射手座";}
        if (month == 11 && date > 30) {value = "Invalid Date";}
        if (month == 12 && date >=22 || month == 1 && date <=19) {value = "摩羯座";}
        if (month == 12 && date > 31) {value = "No way!";}
        return value;
}


